<template>
  <div>
    <el-form ref="form" :rules="rules" :model="form" label-width="300px">
      <el-form-item label="用户下单后超时" prop="litemall_order_comment">
        <el-input
          clearable
          style="width: 600px"
          v-model="form.litemall_order_comment"
          size="mini"
        >
          <template slot="append">分钟</template></el-input
        ><span>用户未付款，则订单自动取消</span>
      </el-form-item>
      <el-form-item label="订单发货后超期" prop="litemall_order_unconfirm">
        <div class="iptsp">
          <el-input
            clearable
            style="width: 600px"
            v-model="form.litemall_order_unconfirm"
            size="mini"
            ><template slot="append">天</template></el-input
          ><span>未确认收货，则订单自动确认收货</span>
        </div>
      </el-form-item>
      <el-form-item label="确认收货后超期" prop="litemall_order_unpaid">
        <el-input
          clearable
          style="width: 600px"
          v-model="form.litemall_order_unpaid"
          size="mini"
          ><template slot="append">天</template></el-input
        ><span>未评价商品，则取消评价资格</span>
      </el-form-item>
      <el-form-item>
        <el-button @click="nono('form')" size="mini">取消</el-button>
        <el-button type="primary" @click="updates('form')" size="mini"
          >确定</el-button
        >
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import { getList, update } from "@/api/configuration/order";
export default {
  data() {
    return {
      form: {},
      rules: {
        litemall_order_comment: [
          { required: true, message: "不能为空", trigger: "blur" },
        ],
        litemall_order_unconfirm: [
          { required: true, message: "不能为空", trigger: "blur" },
        ],
        litemall_order_unpaid: [
          { required: true, message: "不能为空", trigger: "blur" },
        ],
      },
    };
  },
  created() {
    this.getdata();
  },
  methods: {
    getdata() {
      getList().then((res) => {
        console.log(res);
        this.form = res.data;
      });
    },
    updates(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          update(this.form).then((res) => {
            console.log(res);
            if (res.errmsg == "成功") {
              this.$notify({
                title: "成功",
                message: "运费配置修改成功",
                type: "success",
              });
              this.getdata();
            }
          });
        }
      });
    },
    //取消
    nono(formName) {
      this.$refs[formName].resetFields();
      this.getdata();
    },
  },
};
</script>

<style lang="scss" scoped>
span {
  margin-left: 10px;
}
</style>